<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{padding: 0; margin: 0; list-style-type: none;}
        .cont{  position: relative;}
        .w{width: 100vw; height: 100vh; flex: none; position: absolute; transition: all 1s;}
        .c1{ background-color: red; z-index: 2;}
        .c2{ background-color: blue; z-index: 1;}
        .c3{ background-color: green; z-index: 0;}
        .ani{ animation: lefts 1s ease-out;}
        .ani1{ animation: rights 1s ease-out;}
        @keyframes lefts{
            to{
                transform:translateX(-100%);
                opacity: 0;
            }
        }
        @keyframes rights{
            to{
                transform:translateX(100%);
                opacity: 0;
            }
        }
    </style>
</head>
<body>
    <div class="cont">
        <div class="w c1"><button id="dianji">下一步</button><button id="eianji">上一步</button></div>
        <div class="w c2"><button id="dianji1">下一步1</button><button id="eianji1">上一步1</button></div>
        <div class="w c3"><button id="eianji2">上一步2</button></div>
    </div>
    <script type="text/javascript">
        let dianji = document.querySelector('#dianji');
        let dianji1 = document.querySelector('#dianji1');
        let dianji2 = document.querySelector('#dianji2');
        let w = document.querySelectorAll('.w');
        dianji.onclick = function(){
              let c1 = document.querySelector('.c1');
              c1.classList.add('ani');
              c1.addEventListener('animationend', function(){
                  c1.style.display = 'none';
              })
        }
        dianji1.onclick = function(){
            let c2 = document.querySelector('.c2');
            c2.classList.add('ani');
            c2.addEventListener('animationend', function(){
                c2.style.display = 'none';
            })
        }
        let eianji = document.querySelector('#eianji');
        let eianji1 = document.querySelector('#eianji1');
        let eianji2 = document.querySelector('#eianji2');
        eianji2.onclick = function(){
            let c3 = document.querySelector('.c3');
            let c2 = document.querySelector('.c2');
            for(let i = 0; i < w.length; i++){
                w[i].style.display = 'block';
                w[i].classList.remove('ani');
            }
            c2.style.cssText="z-index:3;";
            c3.classList.add('ani1');
            c3.addEventListener('animationend', function(){
                c3.style.display = 'none';
            })
        }
    </script>
</body>
</html>